package jax.io;

/**
 * ...
 * @author tom
 */
 #if sys
import sys.FileSystem;
import sys.io.File;
#end
class JFile {
	var path:String;
	public function new (f:Dynamic, ?s:Dynamic) {
		if(Std.is(f, String) && s == null) {
			#if sys
				if(FileSystem.exists(f))
					path = FileSystem.fullPath(f);
				else
			#end
			path = f;
		}
	}
	public function exists():Bool {
		#if sys
			return FileSystem.exists(path);
		#else
			return false;
		#end
	}
	public function isDirectory():Bool {
		#if sys
		return FileSystem.isDirectory(path);
		#else
		return false;
		#end
	}
	public function createNewFile() {
		#if sys
			File.saveContent(path, "");
		#end
	}
	public function getAbsolutePath():String {
		#if sys
		return FileSystem.fullPath(path);
		#else
		return path;
		#end
	}
	public function lastModified() {
		#if sys
		return FileSystem.stat(path).mtime.getTime();
		#else
		return 00;
		#end
	}
}